package net.jdm.domain.caculator;

import java.util.List;
import java.util.Map;

import net.jdm.common.HashSetExt;
import net.jdm.domain.entity.Component;
import net.jdm.domain.entity.ContainerNode;
import net.jdm.domain.entity.Package;

public final class JavaPackageCycleCaculator extends CycleCaculator {
   private static final JavaPackageCycleCaculator CACULATOR=new JavaPackageCycleCaculator();
   private JavaPackageCycleCaculator(){
   }
   public static JavaPackageCycleCaculator getInstance(){
	   return CACULATOR;
   }
   @Override
   public void collectCycles(List<ContainerNode> path,Map<HashSetExt<ContainerNode>, List<ContainerNode>> resultCycles,ContainerNode currentNode){
		Component beforeComponent=null;
		if(!path.isEmpty())
			beforeComponent=((Package)path.get(path.size()-1)).getComponent();
		if(beforeComponent==null||beforeComponent.equals(((Package)currentNode).getComponent())){
			super.collectCycles(path, resultCycles, currentNode);
		}
   }
}
